/*   1:    */ package org.jetbrains.debugger;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.debugger.values.FunctionValue;
import org.jetbrains.debugger.values.Value;

import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */ 
/*  14:    */ public final class ValueModifierUtil
/*  15:    */ {
/*  16: 15 */   private static final Pattern a = Pattern.compile("[\\p{L}_$]+[\\d\\p{L}_$]*");
/*  17: 19 */   private static final String[] b = new String[''];
/*  18:    */   
/*  19:    */   static
/*  20:    */   {
/*  21: 20 */     for (int i = 0; i <= 31; i++) {
/*  22: 21 */       b[i] = String.format("\\u%04x", new Object[] { Integer.valueOf(i) });
/*  23:    */     }
/*  24: 23 */     b[34] = "\\\"";
/*  25: 24 */     b[92] = "\\\\";
/*  26: 25 */     b[9] = "\\t";
/*  27: 26 */     b[8] = "\\b";
/*  28: 27 */     b[10] = "\\n";
/*  29: 28 */     b[13] = "\\r";
/*  30: 29 */     b[12] = "\\f";
/*  31:    */   }
/*  32:    */   
/*  33:    */   public static ActionCallback setValue(@NotNull final Variable paramVariable, String paramString, @NotNull final EvaluateContext paramEvaluateContext, @NotNull ValueModifier paramValueModifier)
/*  34:    */   {
/*  35: 33 */     if (paramVariable == null) {
/*  36: 33 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/ValueModifierUtil", "setValue" }));
/*  37:    */     }
/*  38: 33 */     if (paramEvaluateContext == null) {
/*  39: 33 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/jetbrains/debugger/ValueModifierUtil", "setValue" }));
/*  40:    */     }
/*  41: 33 */     if (paramValueModifier == null) {
/*  42: 33 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "3", "org/jetbrains/debugger/ValueModifierUtil", "setValue" }));
/*  43:    */     }
/*  44: 33 */     final ActionCallback localActionCallback = new ActionCallback();
/*  45: 34 */     paramEvaluateContext.evaluate(paramString).doWhenDone(new Consumer()
/*  46:    */     {
/*  47:    */       public void consume(Value paramAnonymousValue)
/*  48:    */       {
/*  49: 37 */         this.val$modifier.setValue(paramVariable, paramAnonymousValue, paramEvaluateContext).notify(localActionCallback);
/*  50:    */       }
/*  51: 37 */     }).notifyWhenRejected(localActionCallback);
/*  52:    */     
/*  53:    */ 
/*  54: 40 */     return localActionCallback;
/*  55:    */   }
/*  56:    */   
/*  57:    */   @NotNull
/*  58:    */   public static AsyncResult<Value> evaluateGet(@NotNull ObjectProperty paramObjectProperty, @NotNull EvaluateContextAdditionalParameter paramEvaluateContextAdditionalParameter, @NotNull EvaluateContext paramEvaluateContext, @NotNull String paramString)
/*  59:    */   {
/*  60: 48 */     if (paramObjectProperty == null) {
/*  61: 48 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/ValueModifierUtil", "evaluateGet" }));
/*  62:    */     }
/*  63: 48 */     if (paramEvaluateContextAdditionalParameter == null) {
/*  64: 48 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/debugger/ValueModifierUtil", "evaluateGet" }));
/*  65:    */     }
/*  66: 48 */     if (paramEvaluateContext == null) {
/*  67: 48 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/jetbrains/debugger/ValueModifierUtil", "evaluateGet" }));
/*  68:    */     }
/*  69: 48 */     if (paramString == null) {
/*  70: 48 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "3", "org/jetbrains/debugger/ValueModifierUtil", "evaluateGet" }));
/*  71:    */     }
/*  72: 48 */     FunctionValue localFunctionValue = paramObjectProperty.getGetter();
/*  73: 49 */     if (localFunctionValue == null) {
/*  74: 50 */       throw new RuntimeException("Getter is not a function");
/*  75:    */     }
/*  76: 53 */     StringBuilder localStringBuilder = new StringBuilder(paramString);
/*  77: 54 */     appendName(localStringBuilder, paramObjectProperty.getName(), false); AsyncResult 
/*  78: 55 */       tmp232_229 = paramEvaluateContext.evaluate(localStringBuilder.toString(), Collections.singletonMap(paramString, paramEvaluateContextAdditionalParameter)).doWhenDone(new Consumer());
/*  79: 55 */     if (tmp232_229 == null) {
/*  80: 55 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/ValueModifierUtil", "evaluateGet" }));
/*  81:    */     }
/*  82: 55 */     return tmp232_229;
/*  83:    */   }
/*  84:    */   
/*  85:    */   public static String propertyNamesToString(List<String> paramList, boolean paramBoolean)
/*  86:    */   {
/*  87: 64 */     StringBuilder localStringBuilder = new StringBuilder();
/*  88: 65 */     for (int i = paramList.size() - 1; i >= 0; i--)
/*  89:    */     {
/*  90: 66 */       String str = (String)paramList.get(i);
/*  91: 67 */       boolean bool = (paramBoolean) && ((str.charAt(0) == '"') || (str.charAt(0) == '\''));
/*  92: 68 */       appendName(localStringBuilder, str, bool);
/*  93:    */     }
/*  94: 70 */     return localStringBuilder.toString();
/*  95:    */   }
/*  96:    */   
/*  97:    */   public static void appendName(@NotNull StringBuilder paramStringBuilder, @NotNull String paramString, boolean paramBoolean)
/*  98:    */   {
/*  99: 74 */     if (paramStringBuilder == null) {
/* 100: 74 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/ValueModifierUtil", "appendName" }));
/* 101:    */     }
/* 102: 74 */     if (paramString == null) {
/* 103: 74 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/debugger/ValueModifierUtil", "appendName" }));
/* 104:    */     }
/* 105: 74 */     int i = (!paramBoolean) && (a.matcher(paramString).matches()) ? 1 : 0;
/* 106: 75 */     if (paramStringBuilder.length() != 0) {
/* 107: 76 */       paramStringBuilder.append(i != 0 ? '.' : '[');
/* 108:    */     }
/* 109: 78 */     if (i != 0)
/* 110:    */     {
/* 111: 79 */       paramStringBuilder.append(paramString);
/* 112:    */     }
/* 113:    */     else
/* 114:    */     {
/* 115: 82 */       if (paramBoolean) {
/* 116: 83 */         paramStringBuilder.append(paramString);
/* 117:    */       } else {
/* 118: 86 */         escape(paramString, paramStringBuilder);
/* 119:    */       }
/* 120: 88 */       paramStringBuilder.append(']');
/* 121:    */     }
/* 122:    */   }
/* 123:    */   
/* 124:    */   public static void escape(CharSequence paramCharSequence, StringBuilder paramStringBuilder)
/* 125:    */   {
/* 126: 93 */     int i = paramCharSequence.length();
/* 127: 94 */     paramStringBuilder.ensureCapacity(paramStringBuilder.capacity() + i + 2);
/* 128: 95 */     paramStringBuilder.append('"');
/* 129: 96 */     int j = 0;
/* 130: 97 */     for (int k = 0; k < i; k++)
/* 131:    */     {
/* 132: 98 */       int m = paramCharSequence.charAt(k);
/* 133:    */       String str;
/* 134:100 */       if (m < 128)
/* 135:    */       {
/* 136:101 */         str = b[m];
/* 137:102 */         if (str == null) {
/* 138:    */           continue;
/* 139:    */         }
/* 140:    */       }
/* 141:106 */       else if (m == 8232)
/* 142:    */       {
/* 143:107 */         str = "\\u2028";
/* 144:    */       }
/* 145:    */       else
/* 146:    */       {
/* 147:109 */         if (m != 8233) {
/* 148:    */           continue;
/* 149:    */         }
/* 150:110 */         str = "\\u2029";
/* 151:    */       }
/* 152:115 */       if (j < k) {
/* 153:116 */         paramStringBuilder.append(paramCharSequence, j, k);
/* 154:    */       }
/* 155:118 */       paramStringBuilder.append(str);
/* 156:119 */       j = k + 1;
/* 157:    */     }
/* 158:121 */     if (j < i) {
/* 159:122 */       paramStringBuilder.append(paramCharSequence, j, i);
/* 160:    */     }
/* 161:124 */     paramStringBuilder.append('"');
/* 162:    */   }
/* 163:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.debugger.ValueModifierUtil

 * JD-Core Version:    0.7.0.1

 */